package cn.fenqing168.nio;

import java.nio.IntBuffer;

/**
 * @author fenqing
 */
public class BasicBuffer {

    public static void main(String[] args) {

        //创建一个Buffer
        IntBuffer intBuffer = IntBuffer.allocate(5);
        //往Buffer添加数据
        for (int i = 0; i < intBuffer.capacity(); i++) {
            intBuffer.put(i);
        }
        //切换成读模式
        intBuffer.flip();
        //进行读取数据
        while (intBuffer.hasRemaining()){
            System.out.println(intBuffer.get());
        }

    }

}
